Skip to content

fix(rqlite): validate node via X-Rqlite-Version header before first query#504

Open
mustafash0099 wants to merge 2 commits into
outerbase:developfrom
mustafash0099:fix/59-rqlite-connection-validation
Open

fix(rqlite): validate node via X-Rqlite-Version header before first query#504
mustafash0099 wants to merge 2 commits into
outerbase:developfrom
mustafash0099:fix/59-rqlite-connection-validation

Conversation

@mustafash0099
Copy link
Copy Markdown

Problem

When connecting to an rqlite endpoint, Outerbase Studio would fail or return confusing errors if the configured URL pointed to a non-rqlite server (wrong host, wrong port, or misconfigured proxy).

Fixes #59

Solution

Before executing any SQL, RqliteQueryable now probes the configured endpoint with GET / and verifies the X-Rqlite-Version response header is present, as recommended by the rqlite maintainer in the issue and the rqlite CLI source.

Changes

src/drivers/database/rqlite.ts

  • Added testConnection(): Promise method that calls GET / with redirect: manual
  • Throws a descriptive error when the X-Rqlite-Version header is absent or the host is unreachable
  • Auth credentials are excluded from the probe (the rqlite root path is a public health-check endpoint)
  • transaction() calls testConnection() on first use; result is cached so no overhead on subsequent calls

src/drivers/database/rqlite.test.ts (new)

  • transformRawResult: column mapping, empty rows, duplicate column renaming
  • testConnection: resolves on valid header, throws on missing header, throws on network error, does NOT send auth during probe
  • transaction: validates before first query, skips on subsequent calls, propagates probe failure, sends auth on query requests
  • query: validates and returns first result set

Test plan

  • Run npm test -- all new tests pass, no existing tests broken
  • Connect to a valid rqlite node -- queries execute as before
  • Enter a wrong host/port -- clear error: Cannot reach rqlite at ...
  • Enter a non-rqlite HTTP server -- clear error: does not appear to be an rqlite node

/claim #59

…uery

Before executing any SQL, probe the configured endpoint with GET /
and verify the X-Rqlite-Version response header is present, as
recommended by the rqlite project maintainer.

- Add RqliteQueryable.testConnection() — throws with a clear message
  when the endpoint is unreachable or is not an rqlite node
- Call testConnection() lazily inside transaction() on first use;
  result is cached so subsequent calls pay no overhead
- Auth credentials are intentionally omitted from the probe request
  (the rqlite root path is a public health-check endpoint)
- Add rqlite.test.ts covering: transformRawResult, testConnection,
  transaction integration, and query delegation

Closes outerbase#59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Call to /status to ensure it is valid rqlite node

1 participant